package org.goldenport.g3.events.sql

import org.goldenport.g3.events._
import org.goldenport.g3.messages.RecordSet
import org.goldenport.g3.messages.sql._

/**
 * @since   Jun. 10, 2010
 * @version Oct.  5, 2010
 * @author  ASAMI, Tomoharu
 */
trait SqlEvent extends SqlMessage

class SqlCreated(uri: String, val sql: SqlCreate,
                   val statement: String) extends Mkcoled(uri) with SqlEvent {
  input = Some(sql)
}

class SqlSelected(uri: String, val sql: SqlSelect, val records: RecordSet) extends Getted(uri, Some(records)) with SqlEvent {
  input = Some(sql)
}

class SqlInserted(uri: String, val sql: SqlInsert) extends Posted(uri) with SqlEvent {
  input = Some(sql)
}

class SqlUpdated(uri: String, val sql: SqlUpdate) extends Putted(uri) with SqlEvent {
  input = Some(sql)
}

class SqlDeleted(uri: String, val sql: SqlDelete) extends Deleted(uri) with SqlEvent {
  input = Some(sql)
}

class SqlDropped(uri: String, val sql: SqlDrop,
                   val statement: String) extends Deleted(uri) with SqlEvent {
  input = Some(sql)
}

class SqlExceptioned(
  uri: String, val sql: SqlCommand,
  val statement: String, exception: Exception
) extends CatchExceptioned(uri, exception) with SqlEvent {
  input = Some(sql)
}
